//
//  GifiView.m
//  礼物
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 liangsicheng. All rights reserved.
//

#import "GifiView.h"
#import "SelectionCell.h"
@implementation GifiView



-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}
-(void)createView
{
    
    self.myTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 64,WIDTH, HEIGHT-64) style:UITableViewStylePlain];
    self.myTableView.delegate=self;
    self.myTableView.dataSource=self;
    [self addSubview:self.myTableView];
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.giftCellArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 150*HEIGHT/667;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *indefitier=@"reusethree";
    SelectionCell *cell=[tableView dequeueReusableCellWithIdentifier:indefitier];
    if (cell==nil) {
        cell=[[SelectionCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:indefitier];
    }
    Model *model=[self.giftCellArray objectAtIndex:indexPath.row];
    [cell setModel:model];
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
        Model *model=[self.giftCellArray objectAtIndex:indexPath.row];
        [self.delegate giftPushDetailController:model];
    
}









/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
